//
//  STSettingTableView.m
//  赛拓
//
//  Created by 王磊 on 7/30/16.
//  Copyright © 2016 立金所. All rights reserved.
//

#import "STSettingTableView.h"
#import "STBaseTableViewCell.h"
@interface STSettingTableView()<STBaseViewDelegate>

@end
@implementation STSettingTableView


- (void)commitInit {
    [super commitInit];
    
    self.bounces = false;
    
    [self.dataArray addObjectsFromArray:@[@[@"账号与安全"],@[@"清除本地缓存"],@[@"帮助与反馈",@"关于赛拓"],@[@"退出登录"]]];
}
#pragma mark ---- table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return self.dataArray.count;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return [self.dataArray[section] count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    STBaseTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[NSString stringWithFormat:@"%ld",self.cellType]];
    if (!cell) {
        
        cell = [STBaseTableViewCell baseTableViewCell:self.cellType forIndexPath:indexPath];
    }
    cell.indexPath = indexPath;
    
    [cell updateData:self.dataArray[indexPath.section][indexPath.row] andAccessoryViewData:self.sectionArray[indexPath.section][indexPath.row]];
    
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return [STBaseTableViewCell heightForCell:self.cellType withData:nil forIndexPath:indexPath];
}
- (void)updateData:(id)data forIndexPath:(NSIndexPath *)indexPath {
    
    [self.sectionArray replaceObjectAtIndex:indexPath.section withObject:data];
    
    [self reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 10;
}
- (void)updateData:(id)data {
    
    [self.sectionArray addObjectsFromArray:data];
    
    [self reloadData];
}
@end
